from .base import *

DEBUG = False

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': 'datacenter',
        'USER': 'datacenter',
        'PASSWORD': 'HSMLAiY8Cp3neSrj',
        'HOST': '172.31.40.7',
        # 'HOST': '127.0.0.1',
        'PORT': '3306',
    },
    'datacenter': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': 'reader',
        'USER': 'alvin',
        'PASSWORD': 'Candy.123',
        'HOST': 'master.data.dgut.edu.cn',
        'PORT': '3306',
        'OPTIONS': {
            'init_command': "SET sql_mode='STRICT_TRANS_TABLES'",
            'charset': 'utf8mb4',
        },
    },
    'data_center_by_root': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': 'reader',
        'USER': 'alvin',
        'PASSWORD': 'Candy.123',
        'HOST': 'master.data.dgut.edu.cn',
        'PORT': '3306',
        'OPTIONS': {
            'init_command': "SET sql_mode='STRICT_TRANS_TABLES'",
            'charset': 'utf8mb4',
        },
    },
    'data_center_gxdm_temp': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': 'gxdm_temp',
        'USER': 'etl',
        'PASSWORD': 'Etl123@#',
        'HOST': 'slave01.data.dgut.edu.cn',
        'PORT': '3306',
        'OPTIONS': {
            'init_command': "SET sql_mode='STRICT_TRANS_TABLES'",
            'charset': 'utf8mb4',
        },
    },
    'data_center_gxxs_temp': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': 'gxxs_temp',
        'USER': 'etl',
        'PASSWORD': 'Etl123@#',
        'HOST': 'slave01.data.dgut.edu.cn',
        'PORT': '3306',
        'OPTIONS': {
            'init_command': "SET sql_mode='STRICT_TRANS_TABLES'",
            'charset': 'utf8mb4',
        },
    },
    'data_center_gxzc': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': 'gxzc',
        'USER': 'etl',
        'PASSWORD': 'Etl123@#',
        'HOST': 'slave01.data.dgut.edu.cn',
        'PORT': '3306',
        'OPTIONS': {
            'init_command': "SET sql_mode='STRICT_TRANS_TABLES'",
            'charset': 'utf8mb4',
        },
    },
    'dashboard': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': 'illness_protect',
        'USER': 'ygh',
        'PASSWORD': 'candy.123',
        'HOST': '172.31.200.55',
        'PORT': '3306',
    },
    'donation': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': 'donation',
        'USER': 'donation',
        'PASSWORD': '64tkMntJjL3DWrGD',
        'HOST': '172.31.200.55',
        'PORT': '3306',
    },
    'ibps_business': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': 'business',
        'USER': 'ibps',
        'PASSWORD': 'ibps@dgutlz',
        'HOST': '172.31.200.48',
        'PORT': '3306',
    },
    'ibps_platform': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': 'platform',
        'USER': 'ibps',
        'PASSWORD': 'ibps@dgutlz',
        'HOST': '172.31.200.48',
        'PORT': '3306',
    },
    'illness_protection': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': 'illness_protect',
        'USER': 'django',
        'PASSWORD': 'illness.123',
        'HOST': '172.31.200.55',
        'PORT': '3306',
    },
}

# 用在router类中映射app_label->db name关系

DATABASE_MAPPING = {
    'admin': 'default',
    'auth': 'default',
    'contenttypes': 'default',
    'sessions': 'default',
    'django_celery_beat': 'default',
    'django_celery_results': 'default',
    'PeopleInfo': 'default',
    'DataCenter': 'datacenter',
    'Dashboard': 'dashboard',
    'gxdm_temp': 'data_center_gxdm_temp',
    'gxdm': 'data_center_gxdm_temp',
    'gxzc': 'data_center_gxzc',
    'gxxs': 'datacenter',
    'gxxx': 'datacenter',
    'gxjg': 'datacenter',
    'gxxs_temp': 'data_center_gxxs_temp',
    'gxjg_temp': 'data_center_gxjg_temp',
    'donation': 'donation',
    'ibps_business': 'ibps_business',
    'ibps_platform': 'ibps_platform',
    'illness_protection': 'illness_protection',
}

CACHES = {
    "default": {
        "BACKEND": "django_redis.cache.RedisCache",
        "LOCATION": "redis://172.31.40.7:6379/2",    # redis的地址
        "OPTIONS": {
            "CLIENT_CLASS": "django_redis.client.DefaultClient",
            "SERIALIZER": "django_redis.serializers.json.JSONSerializer",
            "PASSWORD": "candy.123",
            "CONNECTION_POOL_KWARGS": {"max_connections": 100},  # 池的个数
        }
    }
}

# CELERY_BROKER_URL = 'redis://:candy.123@172.31.40.7:6379/1'  # Broker配置，使用Redis作为消息中间件
# CELERY_RESULT_BACKEND = 'redis://:candy.123@172.31.40.7:6379/1'  # BACKEND配置，这里使用redis
CELERY_BROKER_URL = 'amqp://datacenter:candy.123@172.31.40.7:5672/datacenter_vhost'
CELERY_RESULT_BACKEND = 'django-db'  # BACKEND配置，这里使用redis
CELERY_CACHE_BACKEND = 'django-cache'
CELERY_RESULT_SERIALIZER = 'json'  # 结果序列化方案
